/*
    R. J. Cano, Thinking contemplation since (approx. Nov 2011, Jan 12) years ago, finally crystallized in
                the form of the present INFORMAL report on: Oct 13..23, 2016

    Note: Best suitable content for reading it in full width, with a monitor screen resolution of: 1280 per 1024 pixels.
*/

default(timer,1);
read("gpscript.txt"); /* Download this file: https://oeis.org/w/images/4/4c/PARIGPscriptMainlyUsedForRJCanosConjecturesAtseqA217626.txt */
                      /* Then rename to "gpscript.txt" and place it in the same folder containing this script. That's all. */
/*

bash-4.3$ date
Thu Oct 13 15:33:33 VET 2016
bash-4.3$ clear; gp -q -f -s 512000000 ./current.gp


----------------------------------------------------------------------------------------------------------------

 Notation: Those commented lines starting with the "#000" symbol are human wording spoken by the author.
           Any other individual contributing such kind of lines for future versions of this file should
           use "#k" instead, with k>0, and by identifying himself/herself below:

    ------------------------------------------------------------------------------------------------------------
           Id. for people commenting through this file:
             k  name/e-mail
    ------------------------------------------------------------------------------------[list starts]-----------
           000  R. J.Cano (author) / remy@ula.ve or remyatuladotve@gmail.com
    -------------------------------------------------------------------------------------[list ends]------------

           Multi-line comments will be aligned padding with dots(.);

----------------------------------------------------------------------------------------------------------------

 ABSTRACT: Essentially what will be done below is to use the output obtained from the execution of the Steinhaus-Jhonson-Trotter
 
 ( If you wish, you could review it at: https://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm )
 
 generating the first n!-1 differences among permutations for n letters assumed to be the integer numbers in 0..n-1;
 
 Then by observing these described differences seem to behave a very curious and intriguing pattern, where factors consisting of
 powers of "10" are involved, we proceed to analyze separately the distinguishable parts of the obtained terms: Simple integer
 numbers and powers of "10".

 At the time of this submission to OEIS Wiki, they were observed symmetric, anti-symmetric sequences or their modifications,
 recurrence (recursive) patterns, and plausible auto-similarity.
 
 ----------------------------------------------------------------------------------------------------------------
 
 [ NOTE: The mentioned report is self-content in the present script source code, there are no executable demonstrations,
       leaving for the reader the freedom of performing experiments himself/herself; ]
 
 All the work done in the further lies on three definitions: F(), G(), and H();

*/

G(n,d=0,w=1)=if((n>=3)||(#preCompData),vecFirstPartialSums2(vecDiff1(permuteSJT_1(n,d=0,w=1))),[]);

F(n,d=0,w=1,preCompData)=if((n>=3)||(#preCompData),vecRemoveZeroEdges2(if(!#preCompData,G(n,d,w),preCompData)),[]);

/*

#000 Onward, let us focus us in the outputs:

? abs(F(n)) \\ for n=4

      [[1], [2], [3], [1], [3], [1], [2], [2], [2], [3], [1], [1], [1], [2], [3], [1], [3], [1], [2], [2], [2], [3], [1]]

#000 From where we could split such output data as follows:

 Columns: "A" vs. "B"

[[1], [2], [3],
                [1],
 [3], [1], [2],
                [2],
 [2], [3], [1],
                [1],
 [1], [2], [3],
                [1],
 [3], [1], [2],
                [2],
 [2], [3], [1]]

#000 The same thing without abs():

? F(n)

      [[1], [2], [3], [1], [-3], [-1], [-2], [2], [2], [3], [1], [1], [-1], [-2], [-3], [-1], [3], [1], [2], [-2], [-2], [-3], [-1]]

#000 And the corresponding splitting:

      [ [1],  [2],  [3],
                         [1],
       [-3], [-1], [-2],
                         [2],
        [2],  [3],  [1],
                         [1],
       [-1], [-2], [-3],
                         [-1],
        [3],  [1],  [2],
                         [-2],
       [-2], [-3], [-1]]

#000 Surprisingly or not,

? F(n-1)

       [ [1], [2], [1], [-1], [-2] ]

#000 Beyond the fact that the even half of the output for the SJT algorithm partially determines these terms for F(n),
.... as a modification of an anti-symmetric sequence with embedded holes consisting of the output for F(n-1);

....,Up to this point, it seems plausible to state that the output for F(n-1) is distributed inside
.....the output for F(n)

*/

/*

#000 on Friday Oct 14 2016 20:21 GMT;

...The following routine returns 1 if and only if the hypothesis guessed previously
...on the distribution of F(n-1) inside F(n) is true from 1 and up to some n>=1;

*/

Check_nesting_hypothesis(N,preCompData=[])={
  if(N>0,
    my(
       OK=1,
       DATA0=if(!#preCompData,vector(N,x,F(2+x)),preCompData),
       i=1,
       j,
       k
    );
    N=min(N,#DATA0);
    while(i<N,
      j=0;
      k=1;
      while(j<=#DATA0[i+1],
        j+=i+3;
        if(j<=#DATA0[i+1],
          if(DATA0[i+1][j]!=DATA0[i][k],
            print("failing @ ("i+1","j","k");");
            OK=0;
            break
          ,
            k++
          )
        )
      );
      i++
    );
    return(OK)
  )
}

/*

#000 Sample executions:

...Host OS: Linux kernel 4.4.14-smp, Slackware and Slackware64 14.2 releases;

...GP/PARI CALCULATOR Version 2.7.6 (GMP-6.1.1 kernel)

...Hardware 1: x86_64 AMD E-300 APU with Radeon & 4GB RAM;

      N=7;
      ? A=vector(N,x,F(x+2));
      time = 47,686 ms.
      ? Check_nesting_hypothesis(N,A)
      time = 257 ms.
      1

...Hardware 2: i686 Genuine Intel(R) CPU N270 @ 1.60GHz & 1GB RAM;

      N=7;
      ? A=vector(N,x,F(x+2));
      time = 1min, 30,920 ms.
      ? Check_nesting_hypothesis(N,A)
      time = 529 ms.
      1

...It appears to be true!, in addition to the fact that those seqs. are modifications
...of anti-symmetric sequences, and there are at least two ways of turning them into
...anti-symmetric seqs.
...
...Moreover there is revealed that the 1st differences of permutations given by the output of
...Steinhaus-Jhonson-Trotter, divided by "(10-1)" in any given base, are simultaneously both
...recursive and autosimilar (since the algorithm itself determines part of these differences).

#000 Now is the time of looking at the exponents for the power-of-ten factors removed from those terms...

*/

trailingZerosCount(x)={my(c=0,i=1+#x);while(!x[i--],c++);return(c)} /* x is assumed to be a vector */
trailingZerosCount2(w)=vector(#w,i,trailingZerosCount(w[i])); /* w is assumed to be a vector of vectors */

H(n,d=0,w=1,preCompData=[])=trailingZerosCount2(if(#!preCompData,G(n,d,w),preCompData));

/*

#000 The counting sequences given by H() are symmetric!;

      \\ Execution sample as it running on the Hardware #2 described previously:
      N=7;
      ? B=vector(N,x,H(x+2));
      ? time = 1min, 29,256 ms.

       For k=1,2, and 3; the results B[k]=H(k+2) respectively are:
 =--------------------------------------------------------------------------------------=
   k) Pattern found
 =--------------------------------------------------------------------------------------=
   1) 01 0 10
   2) 012 0 210 2 012 0 210 2 012 0 210
   3) 0123 0 3210 2 0123 2 3210 1 0123 2 3210 2 0123 0 3210 3 0123 0 3210 2 0123 2 3210 1 0123 2 3210 2 0123 0 3210 3 0123 0 3210 2 0123 2 3210 1 0123 2 3210 2 0123 0 3210

...As it was observed these symmetric sequences can be split in repeating parts consisting of the first and
...the last permutations in lexicographic order for k+1 letters (particularly here, the first k+1 positive integers starting from zero).
...
...We might remove in each case for k, every repetition of these two mentioned permutations in order to study the resulting pattern:

       The same table shown above, now omitting from them whole permutations
 =--------------------------------------------------------------------------------------=
   k) Revealed pattern
 =--------------------------------------------------------------------------------------=
   1) 0
   2) 0  2  0  2  0
   3) 0  2  2  1  2  2  0  3  0  2  2  1  2  2  0  3  0  2  2  1  2  2  0
...Moreover, we could also include here an extra case:
   4) 0224042203022424220202242422030224042204022404220302242402244144220220202242422030224042204022404220302242422020224242203022404220

...From which by removing the two edge zeros and testing with Symmetry(), as expected we get it verified that such case is symmetric:

   ? Symmetry(digits(224042203022424220202242422030224042204022404220302242422020224242203022404220402240422030224242202022424220302240422))
   time = 1 ms.
   1

...  ( Let us remember that Symmetry(w) gets a vector "w" and returns: 1 if w is symmetric, 2 if w is anti-symmetric, and 0 if none of them. )

...This raises two (interesting?) questions: 1st about to prove that if a sequence is [anti]symmetric, then every subSeq. made from it
...around its center, is also [anti]symmetric; Such "fact" looks trivial, just by definition. A 2nd question is about to determine if
...after removing every [anti]symmetric subSeqs. from a bigger one, the result is [anti]symmetric.

...Now, if we study a sequence with analogy to the elementary set theory, we could state that every sequence "S" always has associated to it
...at least two "other" subSeqs., the empty subSeq. and "S" itself; We might be also interest in the observation of the longest [anti]symmetric
...subSeq. "S0" shorter than "S" that is associated to "S"; Also recursively, the longest [anti]symmetric subSeq. "S1" shorter than "S0" that is
...associated to "S0", and so on (here "is associated to" means "can be obtained from").

...Those palindromes pattern (part of the exponents sequences) can be now described as:

  -----------------
    k) Palindrome   ( Zero edges were removed here for readability, for example for k=3 it should be "0221220" instead of "22122" )
  -----------------
    1) 0
    2) 202
    3) 22122
    4) 2240422
    5) 224414422, 224434422
    6) 22446064422, 22446264422, 22446464422
    7) 2244661664422   (predicted)
    8) 224466808664422 (predicted)

...Each one of these palindromes has 2*k-1 digits. At least the central digit is an alternating Bit ( either 0 or 1 ),
...However there are more possibilities: It can be revealed with additional effort that actually the central digit alternates
...among odd and even numbers.

*/








/*=--------------------------------------------------------------------------------------=
                         Appendix: Foreign helpful source code;
  =--------------------------------------------------------------------------------------=

   Simple programs: "1st" and "fltr";
  
   These 2 Pascal programs ( please visit http://www.freepascal.org/ for getting freely multi-platform support on Pascal compilers )
   were extremely helpful in the middle of the present research. Both are original source code from the same author, released under GPL 3.0
   license as companion content for the featured scripts. Both programs works over the standard input by unix/linux pipelines.
   
   "1st", Reads the first N characters from the standard input and print them. If a huge data stream consisting of printable characters
          is to be analyzed in the hope of finding out some kind of pattern, then "1st" could be applied through a pipeline for sampling
          such data.
          
=================[ "1st" source code starts ]=================

      program firstCharsOnly;
        var
        y:string;
        z,
        t:integer;
        u:char;
      begin
        if (paramcount=1) then begin
          y:=paramstr(1);
          val(y,z,t);
          if (t=0) then begin
            while ((t<z)and (not eof())) do begin
      	read(u);
      	write(u);
      	inc(t);
            end;
          end;
        end;
      end.
      
=================[ "1st" source code  ends  ]=================
======


   "fltr", Reads data from the standard input until the first end-of-file (EOF) delimiter is reached.
           It takes from its invocation one or two arguments "arg1" and "arg2" (here it is implicitly
           suggested the usage of double quotes); Behavior: Always removes "arg1" from its input,
           alternatively replaces it with "arg2" in those cases where "arg2" wasn't omitted.
   
=================[ "fltr" source code starts ]=================

      program fltr_2dot0; (* Written by: R. J. Cano, <remyatuladotve@gmail.com> On: Oct 22th 2016, 19:39 GMT *)
      const doNothing : boolean = false;
      var
        target,
        replacement,
        temporal : string;
        oneChar : char;
        target_size,
        temporal_size,
        index,
        shortening : byte;
      begin
        target:=paramstr(1);
        target_size:=length(target);
        replacement:='';
        temporal:='';
        temporal_size:=0;
        if ((1<=paramcount()) and (paramcount()<=2)) then begin
          if (paramcount() = 2) then replacement:=paramstr(2);
          while (NOT eof()) do begin (* Relative to stdin *)
            read(oneChar);
            if ( doNothing ) then begin
      	write(oneChar);
            end else begin
      (* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *)
      (* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=] Troublemaker section starts here! [-=-=-=-=-=-=-=-=-=-=-=-=- *)
      	if (temporal_size < target_size) then begin
      	  temporal:= temporal + oneChar;
      	  inc(temporal_size);
      	  if (eof()) then if (temporal <> target) then write(temporal) else if (replacement <> '') then write(replacement);
      	end else if (temporal_size = target_size) then begin  (* Better to be exaggeratedly paranoid and explicit; *)
      	  if (temporal = target) then begin
      	    if (replacement <> '') then write(replacement);
      	    temporal:=oneChar;
      	    temporal_size:=1;
      	    if (eof()) then write(oneChar);
      	  end else begin (* if (temporal <> target) is true *)
      	    write(temporal[1]);
      	    for index:= 1 to (temporal_size-1) do temporal[index]:=temporal[index+1];
      	    temporal[temporal_size]:=oneChar;
      	    if (eof()) then begin
      	      if (temporal <> target) then write(temporal) else if (replacement <> '') then write(replacement);
      	    end;
      	  end;
      	end;
      (* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *)
      (*  -=-=-=-=-=-=-=-=-=-=-=-=-=-=] Troublemaker section ends here. [-=-=-=-=-=-=-=-=-=-=-=-=- *)
            end;
          end;
        end else begin
          writeln('');
          write(' Usage: ');
          shortening:=length(paramstr(0));
          while ((paramstr(0)[shortening] <> '/') and (1<shortening)) do dec(shortening); (* Removes from program's executable file full path everything except the filename. *)
          inc(shortening);
          for index:= shortening to length(paramstr(0)) do write(paramstr(0)[index]);
          writeln(' "TARGET" ["REPLACEMENT"] # Works over stdin. ');
          writeln(' ( Current binary'+#39+'s full path is: ',paramstr(0),' )');
          writeln('');
        end;
      end.

=================[ "fltr" source code  ends  ]=================
======

*/

/*EOF*/